home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / basic / qbprt.com / QBPRT10.DOC < prev    next >
Encoding:
Text File  |  1989-05-14  |  13.4 KB  |  533 lines

  1.  
  2.                                   QbPrt   V 1.0
  3.  
  4.       Copyright 1989 (C)    L.Weinman 121 Valdivia Cir. San Ramon, CA USA
  5.       ____________________________________________________________________
  6.  
  7.       Legal stuff:
  8.  
  9.       This copyrighted program is licensed for non-commercial use without
  10.       cost . No charge may be made by anyone other than the copyright
  11.       holder for this program, except for a nominal fee for copying and
  12.       distribution. It may not be included, or bundled, with any materials
  13.       for which a charge is made. Commercial distribution, or use, may only
  14.       be made with the agreement of the copyright holder.
  15.  
  16.       In other words, give it to others for free and don't use it for work,
  17.       or profit, without obtaining a commercial license. (cheap)
  18.  
  19.       Any distribution of the program QbPrt must include this document.
  20.       ____________________________________________________________________
  21.  
  22.  
  23.  
  24.       This program is intended to make QuickBasic (C) source code more
  25.       readable by indenting the logical structures to make them more
  26.       obvious. It will also produce an output suitable for printing.
  27.  
  28.       I wrote it because I was not satisfied with the programs that I had
  29.       seen. If you are not satisfied with it, please let me know, and I
  30.       will examine your complaints, and suggestions, and perhaps
  31.       incorporate them in future editions. I won't know if you are unhappy
  32.       if you don't tell me.
  33.  
  34.  
  35.       If you are a non-commercial user, and like the program, then small
  36.       gifts are always welcome.
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.                                                                 Pg. 1
  61.  
  62.  
  63.  
  64.  
  65.  
  66.       I have tried to make the program self-explanatory.
  67.  
  68.       After starting the program, select either
  69.  
  70.                     1    =    Pretty A QuickBasic Source File
  71.                     2    =    Print A File"
  72.  
  73.       by pressing key 1 or 2.
  74.  
  75.       If you select 1:
  76.  
  77.       The program will then prompt you for the left margin you want, with
  78.       the default 0. (QuickBasic will always set labels flush left)
  79.  
  80.       Then answer for the desired number of spaces to use for the structure
  81.       indent, with the default 4.
  82.  
  83.       Answer Y if you want the first letters of the source code
  84.       capitalized, with the default being No. I personally find first
  85.       capitals to be esthetically pleasing, but you should be cautious if
  86.       your program involves matching embeded strings. QuickBasic will
  87.       automatically set all reserved words to capitals.
  88.  
  89.       Answer Y if you want the program to delete empty lines.
  90.  
  91.       Answer Y if you want the source code to be displayed on the screen as
  92.       it is being processed.
  93.  
  94.       Press the key corresponding to the drive that the source is located
  95.       on.
  96.  
  97.       Select and enter the file you wish to prettify.
  98.  
  99.       Enter the name you wish to give the prettified source code, including
  100.       the drive if applicable.
  101.  
  102.       QbPrt will then process the selected input file, and write it to the
  103.       named output file.
  104.  
  105.       The processed file should then be loaded into QuickBasic and saved as
  106.       an ASCII file if separate compilation with BC (C) is to be used. This
  107.       will change all of the reserved words back to capitals.
  108.  
  109.       You will then be returned to the initial selection screen.
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.                                                            Pg 2
  122.  
  123.  
  124.  
  125.       If you select 2:
  126.  
  127.       Select the drive that the source code is located on.
  128.  
  129.       Select and enter the file that you wish to print.
  130.  
  131.       Enter the title that you wish to use on the printed file.
  132.  
  133.       Answer where you want the processed file send. Either enter the drive
  134.       and file name to produce a disk file, or enter PRN to send the output
  135.       directly to the printer without saving to disk.
  136.  
  137.       Answer the line length that your printer will accomodate, or that you
  138.       wish.
  139.  
  140.       Answer the number of lines per page that your printer will
  141.       accomodate, or that you wish.
  142.  
  143.       Answer the number of columns that you want for the left margin.
  144.  
  145.       Answer the number of spaces that you want between the numbered lines
  146.       delimiter and the source code.
  147.  
  148.       The program will then process the selected input file, and send it to
  149.       the named destination.
  150.  
  151.       The disk file produced is suitable for printing on a "plain vanilla"
  152.       dot matrix printer that prints the standard IBM/Epson character set.
  153.       If you have a different printer, try it and see what happens.
  154.  
  155.       If you select 9:
  156.  
  157.       QbPrt will end and return to DOS.
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.                                                            Pg. 3
  183.  
  184.  
  185.  
  186.       Limitations:
  187.  
  188.       This program is intended for use with QuickBasic 4.0 or 4.5. I have
  189.       not tried it with TurboBasic (C), and it may, or may not, work.
  190.  
  191.       The         IF ...... THEN  '(REM) comment
  192.                        .
  193.                     (ELSE, ELSEIF)
  194.                        .
  195.                   END IF
  196.  
  197.       structure will cause problems. Don't put a comment on the line with
  198.       the IF ..... THEN.
  199.  
  200.       Don't put anything else, except comments, on lines with labels, if
  201.       the label is embedded in a structure.
  202.  
  203.       If your source file contains tabs, the spacing will not come out
  204.       correct. Certain word processors insert tabs.
  205.  
  206.       These are not  bugs, but a decision on my part. Parsing all of the
  207.       possible variations of labels, structures, embedded strings, and
  208.       comments would significantly slow down the program.
  209.  
  210.       Labels will be flush left. Stand alone comments will be flush left.
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.                                                            Pg. 4
  243.  
  244.  
  245.       The examples below use the same code fragment to demonstrate the
  246.       effect of QBPRT. Note that the margin has been set full left to
  247.       better show the output.
  248.  
  249.       The first is the original source code:
  250.       ===================================================================
  251.  
  252.  
  253.  
  254.       '*********************  READINBIG ************************
  255.  
  256. readin:
  257. GET #1, , readit$
  258. readit$ = UCASE$(readit$)
  259. FOR j = 1 TO LEN(readit$)
  260. IF MID$(readit$, j, 1) < " " THEN MID$(readit$, j, 1) = " "
  261. IF MID$(readit$, j, 1) >= " " AND MID$(readit$, j, 1) < "a" THEN
  262. strip$ = strip$ + MID$(readit$, j, 1)
  263. END IF
  264. NEXT j
  265.  
  266. SELECT CASE stripflag$
  267. CASE "3"
  268. FOR k = 1 TO LEN(strip$)
  269. IF NOT (MID$(strip$, k, 1) = " " AND MID$(strip$, k + 1, 1) = " ") THEN
  270. out$ = out$ + MID$(strip$, k, 1)
  271. END IF
  272. NEXT k
  273. CASE "2"
  274. FOR k = 1 TO LEN(strip$)
  275. IF MID$(strip$, k, 1) <> " " THEN
  276. out$ = out$ + MID$(strip$, k, 1)
  277. END IF
  278. NEXT k
  279. CASE "1"
  280. FOR k = 1 TO LEN(strip$)
  281. SELECT CASE MID$(strip$, k, 1)
  282. CASE "0"
  283. out$ = out$ + "ZERO"
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.                                                            Pg. 5
  303.  
  304.  
  305.  
  306.       The next is the source code after having been prettified.
  307.       ===================================================================
  308.  
  309.  
  310.  
  311. '*********************  Readinbig ************************
  312. Readin:
  313.     Get #1, , Readit$
  314.     Readit$ = Ucase$(Readit$)
  315.     For J = 1 To Len(Readit$)
  316.         If Mid$(Readit$, J, 1) < " " Then Mid$(Readit$, J, 1) = " "
  317.         If Mid$(Readit$, J, 1) >= " " And Mid$(Readit$, J, 1) < "A" Then
  318.               Strip$ = Strip$ + Mid$(Readit$, J, 1)
  319.         End If
  320.     Next J
  321.     Select Case Stripflag$
  322.         Case "3"
  323.             For K = 1 To Len(Strip$)
  324.                 If Not (Mid$(Strip$, K, 1) = " " And Mid$(Strip$, K + 1, 1) = " ") Then
  325.                       Out$ = Out$ + Mid$(Strip$, K, 1)
  326.                 End If
  327.             Next K
  328.         Case "2"
  329.             For K = 1 To Len(Strip$)
  330.                 If Mid$(Strip$, K, 1) <> " " Then
  331.                       Out$ = Out$ + Mid$(Strip$, K, 1)
  332.                 End If
  333.             Next K
  334.         Case "1"
  335.             For K = 1 To Len(Strip$)
  336.                 Select Case Mid$(Strip$, K, 1)
  337.                     Case "0"
  338.                         Out$ = Out$ + "Zero"
  339.  
  340.  
  341.  
  342.       Notice that the options were set for
  343.                         indent = 4
  344.                         capitalize first letters
  345.                         remove empty lines
  346.  
  347.       Especially note that the embedded string "ZERO" was changed to
  348.       "Zero". Don't let this bite you!
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.                                                            Pg. 6
  363.  
  364.  
  365.  
  366.  
  367.       The next is the prettified file after having been reloaded into QB.
  368.  
  369.       ===================================================================
  370.  
  371.  
  372. '*********************  Readinbig ************************
  373. Readin:
  374.     GET #1, , Readit$
  375.     Readit$ = UCASE$(Readit$)
  376.     FOR J = 1 TO LEN(Readit$)
  377.         IF MID$(Readit$, J, 1) < " " THEN MID$(Readit$, J, 1) = " "
  378.         IF MID$(Readit$, J, 1) >= " " AND MID$(Readit$, J, 1) < "A" THEN
  379.               Strip$ = Strip$ + MID$(Readit$, J, 1)
  380.         END IF
  381.     NEXT J
  382.     SELECT CASE Stripflag$
  383.         CASE "3"
  384.             FOR K = 1 TO LEN(Strip$)
  385.                 IF NOT (MID$(Strip$, K, 1) = " " AND MID$(Strip$, K + 1, 1) = " ") THEN
  386.                       Out$ = Out$ + MID$(Strip$, K, 1)
  387.                 END IF
  388.             NEXT K
  389.         CASE "2"
  390.             FOR K = 1 TO LEN(Strip$)
  391.                 IF MID$(Strip$, K, 1) <> " " THEN
  392.                       Out$ = Out$ + MID$(Strip$, K, 1)
  393.                 END IF
  394.             NEXT K
  395.         CASE "1"
  396.             FOR K = 1 TO LEN(Strip$)
  397.                 SELECT CASE MID$(Strip$, K, 1)
  398.                     CASE "0"
  399.                         Out$ = Out$ + "Zero"
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.                                                            Pg. 7
  424.  
  425.  
  426.  
  427.  
  428.  
  429.       The next is an example of the output of the printing mode of the
  430.       program. Note that the left margin was set to 0, the right margin was
  431.       set to 79, and the space between the | and the code was set to 2.
  432.  
  433.       ===================================================================
  434.  
  435.  
  436.  
  437. Fragment.Bas                                                         Page # 1
  438. 05-14-1989                                                             21:48:44
  439. ===============================================================================
  440. 1     |  '*********************  Readinbig ************************
  441. 2     |  Readin:
  442. 3     |      GET #1, , Readit$
  443. 4     |      Readit$ = UCASE$(Readit$)
  444. 5     |      FOR J = 1 TO LEN(Readit$)
  445. 6     |          IF MID$(Readit$, J, 1) < " " THEN MID$(Readit$, J, 1) = " "
  446. 7     |          IF MID$(Readit$, J, 1) >= " " AND MID$(Readit$, J, 1) < "A" T»
  447.          »HEN
  448. 8     |                Strip$ = Strip$ + MID$(Readit$, J, 1)
  449. 9     |          END IF
  450. 10    |      NEXT J
  451. 11    |      SELECT CASE Stripflag$
  452. 12    |          CASE "3"
  453. 13    |              FOR K = 1 TO LEN(Strip$)
  454. 14    |                  IF NOT (MID$(Strip$, K, 1) = " " AND MID$(Strip$, K +»
  455.          » 1, 1) = " ") THEN
  456. 15    |                        Out$ = Out$ + MID$(Strip$, K, 1)
  457. 16    |                  END IF
  458. 17    |              NEXT K
  459. 18    |          CASE "2"
  460. 19    |              FOR K = 1 TO LEN(Strip$)
  461. 20    |                  IF MID$(Strip$, K, 1) <> " " THEN
  462. 21    |                        Out$ = Out$ + MID$(Strip$, K, 1)
  463. 22    |                  END IF
  464. 23    |              NEXT K
  465. 24    |          CASE "1"
  466. 25    |              FOR K = 1 TO LEN(Strip$)
  467. 26    |                  SELECT CASE MID$(Strip$, K, 1)
  468. 27    |                      CASE "0"
  469. 28    |                          Out$ = Out$ + "Zero"
  470.  
  471.  
  472.  
  473.       Notice that line 14, the IF NOT .... line contained in CASE "3", no
  474.       longer runs off the right margin of the page.
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.          ----------------end-of-author's-documentation---------------
  500.  
  501.                         Software Library Information:
  502.  
  503.                    This disk copy provided as a service of
  504.  
  505.                         The Public (Software) Library
  506.  
  507.          We are not the authors of this program, nor are we associated
  508.          with the author in any way other than as a distributor of the
  509.          program in accordance with the author's terms of distribution.
  510.  
  511.          Please direct shareware payments and specific questions about
  512.          this program to the author of the program, whose name appears
  513.          elsewhere in  this documentation. If you have trouble getting
  514.          in touch with the author,  we will do whatever we can to help
  515.          you with your questions. All programs have been tested and do
  516.          run.  To report problems,  please use the form that is in the
  517.          file PROBLEM.DOC on many of our disks or in other written for-
  518.          mat with screen printouts, if possible.  The P(s)L cannot de-
  519.          bug programs over the telephone.
  520.  
  521.          Disks in the P(s)L are updated monthly, so if you did not get
  522.          this disk  directly from the P(s)L,  you should be aware that
  523.          the files in this set may no  longer be the current versions.
  524.  
  525.          For a copy of the latest monthly software library newsletter
  526.          and a list of the 1,800+ disks in the library, call or write
  527.  
  528.                         The Public (Software) Library
  529.                               P.O.Box 35705 - F
  530.                            Houston, TX 77235-5705
  531.                                (713) 665-7017
  532.  
  533.